package classpath

import (
	"os"
	"path/filepath"
	"strings"
)

//目录下通配符
///jre/*.jar 不能匹配 /jre/*/*.jar
func newWildcardEntry(path string) CompositeEntry {
	baseDir := path[:len(path)-1] //移除最后的*
	compositeEntry := []Entry{}
	walkFu := func(path string, info os.FileInfo, err error) error {
		if err != nil {
			return err
		}
		if info.IsDir() && path != baseDir {
			return filepath.SkipDir
		}
		if strings.HasSuffix(path, ".jar") || strings.HasSuffix(path, ".jAR") {
			jarEntry:=newZipEntry(path)
			compositeEntry = append(compositeEntry,jarEntry)
		}
		return nil
	}
	filepath.Walk(baseDir, walkFu)
	return compositeEntry

}
